//
//  GroupBuyingCell.m
//  phmall
//
//  Created by admin on 2017/10/12.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "GroupBuyingCell.h"

@implementation GroupBuyingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    GroupBuyingCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[GroupBuyingCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor=[UIColor groupTableViewBackgroundColor];
        
        self.back=[[UIView alloc]init];
        self.back.backgroundColor=[UIColor whiteColor];
        ViewBorderRadius(self.back, 5, 0, [UIColor clearColor]);
        [self.contentView addSubview:self.back];
        
        
        self.goodsImage=[[UIImageView alloc]init];
        self.goodsImage.image=[UIImage imageNamed:@"图片"];
        ViewBorderRadius(self.goodsImage, 5, 0, [UIColor clearColor]);
        [self.back addSubview:self.goodsImage];
        
        self.name=[[UILabel alloc]init];
        self.name.text=@"MASA 女高跟鞋";
        self.name.textColor=[UIColor blackColor];
        self.name.font=[UIFont systemFontOfSize:15];
        [self.back addSubview:self.name];
        
//        self.message =[[UILabel alloc]init];
//        self.message.text=@"四季通穿 时尚百搭 果皮面料";
//        self.message.textColor=[UIColor colorWithHexString:@"#ababab"];
//        self.message.font=[UIFont systemFontOfSize:13];
//        [self.contentView addSubview:self.message];
        
//        self.numberImage=[[UIImageView alloc]init];
//        self.numberImage.image=[UIImage imageNamed:@"56ea394eNb5f936db"];
//        [self.contentView addSubview:self.numberImage];
        
        self.number=[[UILabel alloc]init];
        self.number.text=[NSString stringWithFormat:@"%@%@",@"2",Localized(@"人团购")];
        self.number.textColor=[UIColor colorWithHexString:@"#b2b2b2"];
        self.number.font=[UIFont systemFontOfSize:13];
        [self.back addSubview:self.number];
        
//        self.priceImage=[[UIImageView alloc]init];
//        self.priceImage.image=[UIImage imageNamed:@"56ea394eNb5f936db"];
//        [self.contentView addSubview:self.priceImage];
        
        self.price=[[UILabel alloc]init];
        self.price.text=@"₱334.58";
        self.price.textColor=[UIColor orangeColor];
        self.price.font=[UIFont systemFontOfSize:15];
        [self.back addSubview:self.price];
        
//        self.onePriceText=[[UILabel alloc]init];
//        self.onePriceText.text=@"单买价";
//        self.onePriceText.textColor=[UIColor colorWithHexString:@"#b2b2b2"];
//        self.onePriceText.font=[UIFont systemFontOfSize:16];
//        [self.contentView addSubview:self.onePriceText];
        
//        self.onePriceImage=[[UIImageView alloc]init];
//        self.onePriceImage.image=[UIImage imageNamed:@"56ea394eNb5f936db"];
//        [self.contentView addSubview:self.onePriceImage];
//
        self.onePrice=[[UILabel alloc]init];
        self.onePrice.text=@"₱775.00";
        self.onePrice.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.onePrice.font=[UIFont systemFontOfSize:12];
        [self.onePrice setLabelWithDelLine];
        [self.back addSubview:self.onePrice];
        
        self.open=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.open setTitle:[NSString stringWithFormat:@"%@>",Localized(@"参团")] forState:UIControlStateNormal];
        ViewBorderRadius(self.open, 5, 0, [UIColor clearColor]);
        self.open.titleLabel.font=[UIFont systemFontOfSize:15];
        [self.open setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.open setBackgroundColor:[UIColor orangeColor]];
        [self.back addSubview:self.open];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.right.offset(-10);
        make.top.bottom.offset(0);
    }];
    
    [self.goodsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(10);
        make.width.height.offset(150);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.equalTo(self.goodsImage.mas_bottom).offset(10);
    }];
    
    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.equalTo(self.name.mas_bottom).offset(10);
    }];
    
    [self.onePrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.equalTo(self.price.mas_bottom).offset(10);
    }];
    
    [self.open mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.offset(-10);
        make.width.offset(72);
        make.height.offset(30);
    }];
    
    [self.number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.open.mas_left).offset(-10);
        make.bottom.equalTo(self.open);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}
@end
